﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ETL.Business.Models;
using ETL.Common.Logging;
using ETL.DataAccess;
using ETL.Entity;

namespace ETL.Business.Handlers.ProjectNamesHandler
{
    public class GetSelectedProject
    {
        private readonly ProjectUserRepository _projectUserRepository;

        public GetSelectedProject()
        {
            _projectUserRepository = new ProjectUserRepository();
        }
        public GetSelectedProject(ProjectUserRepository projectUserRepository)
        {
            _projectUserRepository = projectUserRepository;
        }

        public virtual int? Execute(string userId)
        {
            int? result = null;
            try
            {
                // try to get from db
                APP_USERS prjAllNamesItem = 
                    _projectUserRepository.GetUserById(userId);

                // parse to business model
                if(prjAllNamesItem != null)
                {
                    //result =  prjAllNamesItem.ENG_SELECTED_PROJECT;
                    result = null;
                }
                return result;
            }
            catch (Exception ex)
            {
                LogService.Service.Debug(ex);
                return result;
            }
        }
    }
}
